package ru.sgu.diploma.practic;

import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import ru.sgu.diploma.practic.service.StatesGenerator;
import ru.sgu.diploma.practic.service.impl.StatesGeneratorImpl;

/**
 * User: datmakin
 * Date: 14.03.11
 * Email: atmakin.dv@gmail.com
 */
public class StatesGeneratorTestCase {

    @Test
    public void testGenerator() {
        StatesGenerator statesGenerator = new StatesGeneratorImpl();
        String[] alphabet = {"a", "b"};
        for (int i = 0; i < 10; i++){
            String[] ranStr = statesGenerator.generateStateForAlphabet(alphabet);
            assertNotNull(ranStr);
            assertEquals(new Long(ranStr.length), new Long(statesGenerator.getLength()));
            String empty = "";
            for (int j = 0; j < ranStr.length; j++)
                empty += ranStr[j];
            for (int j = 0; j < alphabet.length; j++)
                empty = empty.replace(alphabet[j], "");

            assertTrue(StringUtils.isEmpty(empty));
        }
    }
}
